package com.hades.example.java.refactoring.after.c10.c10_12_replace_constructor_with_factory_method._1;

public class Employee {
    static final int ENGINEER = 0;
    static final int SALES_MAN = 1;
    static final int MANAGER = 2;

    // 根据类型码创建子类
    // 将子类对用户隐藏起来
    static Employee create(int type) {
        switch (type) {
            case ENGINEER:
                return new Engineer();
            case SALES_MAN:
                return new SalesMan();

            case MANAGER:
                return new Manager();
            default:
                throw new IllegalArgumentException("Invalid type code " + type);
        }
    }

    public int maxNum() {
        return 10;
    }
}
